// To parse this JSON data, do
//
//     final chatSessionData = chatSessionDataFromJson(jsonString);

import 'dart:convert';

ChatSessionData chatSessionDataFromJson(String str) => ChatSessionData.fromJson(json.decode(str));

String chatSessionDataToJson(ChatSessionData data) => json.encode(data.toJson());

///
/// 会话列表模型
///
class ChatSessionListData {
  final int limit;
  final bool hasMore;
  final List<ChatSessionData> data;

  ChatSessionListData({
    this.limit = 20,
    this.hasMore = false,
    this.data = const [],
  });

  factory ChatSessionListData.fromJson(Map<String, dynamic> json) => ChatSessionListData(
        limit: json["limit"],
        hasMore: json["has_more"],
        data: json["data"] != null ? List<ChatSessionData>.from(json["data"].map((x) => ChatSessionData.fromJson(x))) : [],
      );

  Map<String, dynamic> toJson() => {
        "limit": limit,
        "has_more": hasMore,
        "data": List<ChatSessionData>.from(data.map((x) => x.toJson())),
      };
}

///
/// 会话模型
///
class ChatSessionData {
  String? id;
  String? name;
  ChatSessionInputs? inputs;
  String? status;
  String? introduction;
  int? createdAt;
  int? updatedAt;

  ChatSessionData({
    this.id,
    this.name,
    this.inputs,
    this.status,
    this.introduction,
    this.createdAt,
    this.updatedAt,
  });

  factory ChatSessionData.fromJson(Map<String, dynamic> json) => ChatSessionData(
        id: json["id"],
        name: json["name"],
        inputs: ChatSessionInputs.fromJson(json["inputs"]),
        status: json["status"],
        introduction: json["introduction"],
        createdAt: json["created_at"],
        updatedAt: json["updated_at"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "inputs": inputs?.toJson(),
        "status": status,
        "created_at": createdAt,
        "updated_at": updatedAt,
      };
}

///
///
///
class ChatSessionInputs {
  final String? book;
  final String? myName;

  ChatSessionInputs({
    this.book,
    this.myName,
  });

  factory ChatSessionInputs.fromJson(Map<String, dynamic> json) => ChatSessionInputs(
        book: json["book"],
        myName: json["myName"],
      );

  Map<String, dynamic> toJson() => {
        "book": book,
        "myName": myName,
      };
}

///
/// 会话重新命名模型
///
class ChatSessionRenameData {
  /// 会话 ID
  final String? id;

  /// 会话名称
  final String? name;

  /// 用户输入参数
  final ChatSessionInputs? inputs;

  /// 会话状态
  final String? status;

  /// 开场白
  final String? introduction;

  /// 创建时间 timestamp
  final int? createdAt;

  /// (timestamp) 更新时间
  final int? updatedAt;

  const ChatSessionRenameData({
    this.id,
    this.name,
    this.inputs,
    this.status,
    this.introduction,
    this.createdAt,
    this.updatedAt,
  });

  factory ChatSessionRenameData.fromJson(Map<String, dynamic> json) => ChatSessionRenameData(
        id: json["id"],
        name: json["name"],
        inputs: ChatSessionInputs.fromJson(json["inputs"]),
        status: json["status"],
        introduction: json["introduction"],
        createdAt: json["created_at"],
        updatedAt: json["updated_at"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
        "inputs": inputs?.toJson(),
        "status": status,
        "introduction": introduction,
        "created_at": createdAt,
        "updated_at": updatedAt,
      };
}
